class Container {
  constructor(value) {
    this._value = value;
  }

  static of (value) {
    return new Container(value);
  }

  map (fn) {
    return new Container(fn(this._value));
  }
}

const c = Container.of(4)
  .map(v => v + 2)
  .map(v => v * v);

console.log(c); // Container { _value: 36 }